#! /bin/bash

np=$1;
npstride=$2;
if  [[ $npstride != 1 ]]
then
    corenum[0]=1
    for i in `seq  $npstride $npstride $np`
    do
        corenum[$(($i/$npstride))]=$i;
        #echo ${corenum[$(($i/$npstride))]} $i
    done
else
    for i in `seq  1 $np`
    do
        corenum[$(($i-1))]=$i;
        #echo ${corenum[$(($i/$npstride))]} $i
    done
fi
total=30
a=24;
b=24;
for exe in 1d-3p
do
    #rm ./$exe-16384.txt 
    rm ./$exe-2048.txt
    for index in `seq $a $b`;
    do 
    nx=$((2 ** $index))
    t=$((2 ** ($total - $index)))
    for i in "${corenum[@]}";
    do
        export OMP_NUM_THREADS=$i;../$exe/exe-$exe 12000000 4000 2048 1000 >> ./$exe-2048.txt 
        echo  $i >> ./1d-3p.cpulist
    done
    done
done


echo -e "np\tGStencils" > ./1d-3p.data.txt
cat ./1d-3p-2048.txt |awk -F "= " '{print $NF}'| paste 1d-3p.cpulist -  | awk '{print $1 "\t" $2 }' >>  ./1d-3p.data.txt
rm ./1d-3p.cpulist
rm ./1d-3p-2048.txt